package com.china.shcool;

import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.server.ErrorPage;
import org.springframework.boot.web.server.WebServerFactoryCustomizer;
import org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory;
import org.springframework.stereotype.Component;

import java.util.HashSet;

@Component
public class MyWebServerFactoryCustomizer implements WebServerFactoryCustomizer<TomcatServletWebServerFactory> {

    @Override
    public void customize(TomcatServletWebServerFactory server) {
        server.setPort(9000);
        HashSet<ErrorPage> objects = new HashSet<>();
        objects.add(new MyErrorPage(
                "/a"
        ));
        server.setErrorPages(objects);

    }

    public  static class MyErrorPage extends ErrorPage {

        public MyErrorPage(String path) {
            super(path);
        }
    }

}

